Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working hlslparser #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Working hlslparser #1

wants to merge 3 commits into from

Conversation

zz85
Copy link

@zz85 zz85 commented Feb 13, 2015

Some work-in-progress to get @Thekla's (The Witness) branch working...

@alecazam
Copy link

alecazam commented Feb 26, 2023

I'm going to tack an important fix here, since there is no "Issues" list. I'll do a proper fork when I have time. For the code to work properly, need the MSL/HLSL generator to call the following in Generate or Prepass. The PruneTree is critical to doing the deadcode strip. The rest of the calls are also probably helpful, for marking hidden unused nodes.

 // PruneTree resets hidden flags to true, then marks visible elements
    // based on whether entry point visits them.
    PruneTree(tree, entryFunction->name); // Note: takes second entry
    
    // This sorts tree by type, but keeps ordering
    SortTree(tree);
   
    // This strips any unused inputs to the entry point function
    HideUnusedArguments(entryFunction);
    
    // Note sure if/where to add these calls.  Just wanted to point
    // out that nothing is calling them, but could be useful.
    //EmulateAlphaTest(tree, entryName, 0.5f);
    FlattenExpressions(tree);

Here's my copy of the code, updated, with a ton of bug fixes. It's also updated to use DX10 syntax, and handles half, has test shaders, and generates clickthrough errors to Xcode. It's generating reasonable HLSL/MSL code from the sources, and not too many modifications are needed (mostly to texture calls). I also build the macOS binary of this in the kram package.

https://github.com/alecazam/kram/tree/main/hlslparser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants